#
# Copyright (C) [2024] Xingyun Integrated Circuit, Inc.
#
# GreenCode was a private technology asset of Xingyun Integrated Circuit， Inc （Confidential）
# Author: Shawn.Tan
# Date: 2025.10.28
#
# History: Initial Version 2025.10.28
#
#
from gpgpu.EnvGPGPU import EnvGPGPU
from gpgpu.GenThreadGPGPU import GenThreadGPGPU
from base.Sequence import Sequence


#  This test verifies that basic load and store instructions can be
#  executed successfully.
class MainSequence(Sequence):
    def generate(self, **kargs):
        instructions = ("LD##CALM", "SD##CALM")
        if self.getGlobalState("AppRegisterWidth") == 32:
            instructions = ("LW##CALM", "SW##CALM")

        for _ in range(1000):
            instr = self.choice(instructions)
            self.genInstruction(instr, {"NoPreamble": 1})

            except_count = 0
            for except_code in (0x2, 0x4, 0x5, 0x6, 0x7, 0xD, 0xF):
                except_count += self.queryExceptionRecordsCount(except_code)

            if except_count != 0:
                self.error("Instruction %s did not execute correctly" % instr)


MainSequenceClass = MainSequence
GenThreadClass = GenThreadGPGPU
EnvClass = EnvGPGPU
